From 6cf7902d214993f6134cea28dc0ab18d624eab0f Mon Sep 17 00:00:00 2001 From: Dario Faggioli Date: Wed, 6 Jun 2012 12:46:17 +0100 Subject: [PATCH] libxl: convert malloc() to libxl__zalloc(NULL, ...) And ditch the error handling in libxl_get_cpu_topology() Signed-off-by: Dario Faggioli Acked-by: Ian Campbell [ ijc -- define and use NOGC instead of NULL to allow improvements to this infrastructure in the future ] Committed-by: Ian Campbell --- tools/libxl/libxl.c | 7 +------ tools/libxl/libxl_internal.h | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 58387ed012..1f7ccc4aea 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -3116,12 +3116,7 @@ libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nr) if (tinfo.max_cpu_index < max_cpus - 1) max_cpus = tinfo.max_cpu_index + 1; - ret = malloc(sizeof(libxl_cputopology) * max_cpus); - if (ret == NULL) { - LIBXL__LOG_ERRNOVAL(ctx, XTL_ERROR, ENOMEM, - "Unable to allocate return value"); - goto fail; - } + ret = libxl__zalloc(NOGC, sizeof(libxl_cputopology) * max_cpus); for (i = 0; i < max_cpus; i++) { #define V(map, i) (map[i] == INVALID_TOPOLOGY_ID) ? \ diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index f647e88d38..fcb5d99f39 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1933,6 +1933,7 @@ struct libxl__domain_create_state { #define GC_INIT(ctx) libxl__gc gc[1]; LIBXL_INIT_GC(gc[0],ctx) #define GC_FREE libxl__free_all(gc) #define CTX libxl__gc_owner(gc) +#define NOGC NULL /* Allocation macros all of which use the gc. */ -- 2.30.2